package com.zelix.tool;

import java.util.Random;

public class ZkmTimeConvert {
    public static long StringToLong(String str) {
        char[] var5 = str.toCharArray();
        char[] var6 = new char[var5.length];

        for (int var7 = 0; var7 < var5.length; ++var7) {

            char var8 = var5[var7];
            //System.out.print(var8 + ":");

            //等于0时不处理，实际运行最后var6[var7] = var8;
            if (var8 > '0' && var8 <= '9') {//48-57
                var8 = (char) (58 - var8 + 48);//58-48+48=58=':'    58-49+48=57='9'....58-56+48=50='2'    58-57+48=49='1'
                //System.out.println(var8);
            }

            if (var8 >= 'A' && var8 <= 'J') {//65-74
                var8 = (char) (var8 - 17);//65-17=48='0'   74-17=57='9'
                //System.out.println(var8);
            }

            if (var8 >= 'K' && var8 <= 'T') {//75-84
                var8 = (char) (var8 - 27);//75-27=48='0'   84-27=57='9'
                //System.out.println(var8);
            }

            if (var8 >= 'U' && var8 <= 'Z') {//85-90
                var8 = (char) (var8 - 37);//85-37=48='0'   90-37=53='5'
                //System.out.println(var8);
            }

            if (var8 >= 'a' && var8 <= 'd') {//97-100
                var8 = (char) (var8 - 43);//97-43=54='6'   100-43=57='9'
                //System.out.println(var8);
            }

            if (var8 >= 'e' && var8 <= 'n') {//101-110
                var8 = (char) (var8 - 53);//101-53=48='0'   110-53=57='9'
                //System.out.println(var8);
            }

            if (var8 >= 'o' && var8 <= 'x') {//111-120
                var8 = (char) (var8 - 63);//111-63=48='0'   120-63=57='9'
                //System.out.println(var8);
            }

            var6[var7] = var8;
        }

        return Long.parseLong(new String(var6));
    }

    public static String LongToString(long l) {
        char[][] chars = new char[][]{
                {'0', '9', '8', '7', '6', '5', '4', '3', '2', '1'},
                {'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J'},
                {'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T'},
                {'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd'},
                {'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n'},
                {'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x'}
        };

        char[] var5 = (l + "").toCharArray();
        Random rom = new Random();

        for (int i = 0; i < var5.length; i++) {
            var5[i] = chars[rom.nextInt(chars.length)][Integer.parseInt(var5[i] + "")];
        }
        return new String(var5);
    }

    public static void main(String[] args) {
        long l=StringToLong("faOdAmUPY3mhD");
        System.out.println(LongToString(l));
        System.out.println(StringToLong(LongToString(l)));
    }
}
